---
title: "Azure OpenAI"
---

Helicone can be seamlessly integrated with your Azure-OpenAI deployment. This integration requires no additional code changes beyond importing the OpenAI package with Helicone.

<Note>
<b>MODEL OVERRIDE</b>

When using Azure, the model may sometimes display differently than expected. We have implemented a series of logic to parse out the model, but the returned body of the model can be inconsistent in most cases.

<code>Helicone-Model-Override: [MODEL_NAME]</code>
<br/>
<br/>
<a href="/helicone-headers/intro"> Click here to learn more about model override</a>
</Note>

<Tabs>
 <Tab title="Python">
 <Note>Please ensure to include the 'api-version' in all of your requests.</Note>
<AccordionGroup>
  <Accordion title="OpenAI v1+">
  <Note>It is mandatory to include the 'api-key' in both locations.</Note>
  ```python
    client = OpenAI(
      api_key="[AZURE_OPENAI_API_KEY]",
      base_url="https://oai.hconeai.com/openai/deployments/[DEPLOYMENT]",
      default_headers={
          "Helicone-OpenAI-Api-Base": "https://[AZURE_DOMAIN].openai.azure.com",
          "Helicone-Auth": "Bearer [HELICONE_API_KEY]",
          "api-key": "[AZURE_OPENAI_API_KEY]",
      },
      default_query={
          "api-version": "[API_VERSION]"
      
      }
  )
  ```
  </Accordion>

  <Accordion title="OpenAI <v1">
  **Modify the API base and add a Helicone-Auth header**

```python
import openai

openai.api_base = "https://oai.hconeai.com"
openai.api_key = "[AZURE_OPENAI_API_KEY]"
openai.api_version = "[API_VERSION]"
openai.api_type = "azure"

# Create the completion request
openai.ChatCompletion.create(
    model="[DEPLOYMENT]",
    messages=[{"role": "User", "content": "Say hi!"}],
    headers={
        "Helicone-Auth": "Bearer [HELICONE_API_KEY]",
        "Helicone-OpenAI-Api-Base": "https://[AZURE_DOMAIN].openai.azure.com",
    }
)
```

  </Accordion>
</AccordionGroup>
    Congratulations! Your Azure OpenAI requests are now configured to log results to Helicone.
  </Tab>

<Tab title="Node.js">
<Note>Please ensure to include the 'api-version' in all of your requests.</Note>
<AccordionGroup>

  <Accordion title="OpenAI v4+">
    ```typescript
    const openai = new OpenAI({
      baseURL: "https://oai.hconeai.com/openai/deployments/[DEPLOYMENTNAME]",
      defaultHeaders: {
        "Helicone-Auth": `Bearer [HELICONE_API_KEY]`,
        "Helicone-OpenAI-API-Base": "https://[AZURE_DOMAIN].openai.azure.com",
        "api-key": "[AZURE_API_KEY]",
      },
      defaultQuery: { "api-version": "[API_VERSION]" },
    });
    ```
  </Accordion>

  <Accordion title="OpenAI <v4">
    ```typescript
    import { Configuration, OpenAIApi } from "openai";

    const configuration = new Configuration({
      apiKey: "[AZURE_OPENAI_API_KEY]",
      basePath: "https://oai.hconeai.com/openai/deployments/[DEPLOYMENT]",
      baseOptions: {
        headers: {
          "Helicone-Auth": `Bearer [HELICONE_API_KEY]`,
          "api-key": "[AZURE_OPENAI_API_KEY]",
          "Helicone-OpenAI-Api-Base": "https://[AZURE_DOMAIN].openai.azure.com",
        },
        params: {
          "api-version": "[API_VERSION]",
        },
      },
    });

    const openai = new OpenAIApi(configuration);
    ```

  </Accordion>
</AccordionGroup>

</Tab>
<Tab title="Python w/package">

```python
from helicone.openai_proxy import openai
openai.api_type = "azure"
openai.api_base = "https://[YOUR_AZURE_DOMAIN].openai.azure.com"
openai.api_version = "2023-03-15-preview"
openai.api_key = YOUR_AZURE_API_KEY

response = openai.ChatCompletion.create(
engine = 'gpt-35-turbo',
messages = [{
    'role': 'user',
    'content': "Hello World!"
}],
max_tokens=15,
)

```

</Tab>

<Tab title="LangChain JS">

```javascript
const model = new ChatOpenAI({
  azureOpenAIApiKey: "[AZURE_OPENAI_API_KEY]",
  azureOpenAIApiDeploymentName: "openai/deployments/gpt-35-turbo",
  azureOpenAIApiVersion: "2023-03-15-preview",
  azureOpenAIBasePath: "https://oai.hconeai.com",
  configuration: {
    organization: "[organization]",
    baseOptions: {
      headers: {
        "Helicone-Auth": `Bearer ${heliconeApiKey}`,
        "Helicone-OpenAI-Api-Base":
          "https://[YOUR_AZURE_DOMAIN].openai.azure.com",
      },
    },
  },
});
```

</Tab>

<Tab title="LangChain">

```python
from langchain.chat_models import AzureChatOpenAI
helicone_headers = {
    "Helicone-Auth": f"Bearer {helicone_api_key}",
    "Helicone-OpenAI-Api-Base":
        "https://<model_name>.openai.azure.com/"
}
self.model = AzureChatOpenAI(
openai_api_base="https://oai.hconeai.com",
deployment_name="gpt-35-turbo",
openai_api_key=<AZURE_OPENAI_API_KEY>,
openai_api_version="2023-05-15",
openai_api_type="azure",
max_retries=max_retries,
headers=helicone_headers,
**kwargs,
)
```

</Tab>
<Tab title="cURL">
  ```bash
    curl --request POST \
    --url https://oai.hconeai.com/openai/deployments/DEPLOYMENTNAME/chat/completions?api-version=[API_VERSION] \
    --header 'Helicone-Auth: Bearer [HELICONE_KEY]' \
    --header 'Helicone-OpenAI-Api-Base: https://[AZUREDOMAIN].openai.azure.com' \
    --header 'api-key: [AZURE_API_KEY]' \
    --header 'content-type: application/json' \
    --data '{
      "messages": [
        {
          "role": "user",
          "content": "Answer in one word"
        }],
      "max_tokens": 800,
      "temperature": 1,
      "model": "gpt-3.5-turbo-0613"
    }'
  ```
</Tab>
</Tabs>
